/**
 * futures : masterlink.futures.controller.IndexController.java
 */
package masterlink.futures.controller;

import javax.servlet.http.HttpServletRequest;

import masterlink.futures.util.Constant;
import masterlink.futures.util.WebUtils;

import org.slf4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import baytony.util.StringUtil;
import baytony.util.log.Log;

/**
 * TODO Write the description
 *
 * @author : tonyyang
 * Create date : 2011/9/30
 * @version 1.0.0	
 */
@Controller
@Transactional
public class BasicController {
	
	protected Logger log=Log.getLogger(this.getClass());
	
	@RequestMapping(method=RequestMethod.GET)
	public String index(HttpServletRequest req){
		return "data/index";
	}
	
	 @ExceptionHandler(Exception.class)
     public String handleException(Exception ex,HttpServletRequest req) {
		 log.error("Error in path {}, msg : {}",WebUtils.getFullPath(req),ex);
		 log.error(StringUtil.getStackTraceAsString(ex));
		 req.setAttribute(Constant.EXCEPTION, ex);
		 req.setAttribute(Constant.ERROR_MSG, WebUtils.getFullPath(req));
       return "error/error";
     }
	
}
